<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="<?php echo $this->_webroot('skin/css/admin.css'); ?>">
<link rel="stylesheet" type="text/css" href="<?php echo $this->_webroot('skin/css/main.css'); ?>">
<script type='text/javascript' src="<?php echo $this->_webroot('skin/js/jy.js'); ?>"></script>
<script type='text/javascript' src='<?php echo $this->_webroot('servtools/date/WdatePicker.js'); ?>'></script>
<style>
td span {color:red;}
.green {color:green;}
.red {color:red;}
#divname{float:left; margin:0px;}
</style>
</head>
<body>
<input type="hidden" id="update_right" value="1" ></input>
<div id="maincontent">
	<div class="wrap">
	<div class="crumbs">当前位置 &gt;&gt; 商铺管理 &gt;&gt; 商铺列表</div>
        <hr />
	<div class="seachbox">
        <div class="content2">
        	<form action="<?php echo $this->_url('admin/shop/index');?>" name="searchForm" method="get">
            <table class="form-table">
            	<tbody>
            	  <tr>
                   	<td width="10px">
                   		<span style="margin:1px -5px 0px 0px; float:right; color: #000" >
                   			<img src="<?php echo $this->_webroot('skin/images/icon_search.gif'); ?>" border="0" alt="SEARCH" />
                   		</span>
                   	</td>
                    <td >
                    	<span style="margin:1px 2px 0px -10px; float:left; color:#000" >
                    		商铺名称:
                    	</span>
						
                    	<input type="text" class="small-text" name="name" value="<?php echo $name; ?>" style="width:100px" />
						创建时间：
						<input class="Wdate" type="text" name="start_time" id="start_time" onFocus="WdatePicker({isShowClear:false,readOnly:true})" value="<?php echo $start_time;?>" />至
						
						
						<input class="Wdate" type="text" name="end_time" id="end_time" onFocus="WdatePicker({isShowClear:false,readOnly:true})"  value="<?php echo $end_time;?>"/>
						锁定状态：
						<select name='shop_open_status'>
							<option value ="2">全部</option>
							<option value ="1" <?php if($shop_open_status=='1') echo "selected"?>>锁定</option>
							<option value ="0" <?php if($shop_open_status=='0') echo "selected"?>>解除锁定</option>
						</select>
							商铺分类：
							<select name='shop_categorie'>
							<option value ="0">选择分类</option>
						<?php if($category_dg) {
								foreach($category_dg as $value) {
									if($value['parent_id']=='0'){
								?>
									<option value ="<?php echo $value['cat_id'];?>" <?php if($shop_categorie==$value['cat_id']) echo "selected"?>><?php echo $value['cat_name'];?></option>
								<?php } else {?>
									<option value ="<?php echo $value['cat_id'];?>" <?php if($shop_categorie==$value['cat_id']) echo "selected"?>><?php echo "----|".$value['cat_name'];?></option>
								<?php }
								}
							}?>
						</select>
                    </td>
                    <td>
                    <span style="margin:-2px 0px 0px -10px; float:left;" >
                    	<input class="regular-button" type="submit" value="搜索" />
                    </span>
                    </td>
                  </tr>
                </tbody>
            </table>
            </form>
        </div>
    </div>		
		
		
	<div class="infobox">
	<h3>
	<span class="left">商铺列表</span>

	</h3>
    <div class="content2">
			<form action="<?php echo $this->_url('admin/shop/lockshop/');?>" name="form1" id="form1" method="post">
			<table class="list_table">
			  <thead>
                <tr style="text-align: center;">
					<th width="2px"><input type="checkbox" value="" onclick="checkall(this,'shop_id[]');"></th>
					<th width="40px">ID</th>
					<th align="left">店主/商铺名称</th>
					<th width="120px">所在地区</th>
					<th width="100px" align="left">主要经营</th>
					<th width="60px">商铺状态</th>
					<th width="60px">是否推荐</th>
					<th width="80px">认证会员</th>
					<th width="85px">创建时间</th>
					<th width="61px">操作</th>
				</tr>
			  </thead>
			  <tbody>
				<?php if($result['data']) {
				foreach($result['data'] as $value) { ?>
				<tr style="text-align:center;">
					<td width="2px"><input type="checkbox" name="shop_id[]" value="<?php echo $value['shopinfo']['id'];?>" /></td>
					<td width="40px"><?php echo $value['shopinfo']['id'];?>.</td>
					<td width="" align="left"><?php echo $value['user']['username']?><br />
						<a href="../shop.php?shopid=<?php echo $value['shopinfo']['id'];?>&app=index" target="_blank"><?php echo $value['shopinfo']['shop_name'];?></a>
						(<a href="m.php?app=goods_list&shopid=<?php echo $value['shopinfo']['id'];?>">查看商品</a>)
					</td>
					<td><?php echo $areainfo[$value['shopinfo']['shop_province']].','.$areainfo[$value['shopinfo']['shop_city']].','.$areainfo[$value['shopinfo']['shop_district']];?></td>
					<td align="left"><?php echo $value['shopinfo']['shop_management'];?></td>
					<td>
						<?php if($value['shopinfo']['lock_flg']==0) {?>
						解除锁定
						<?php }else{?>
						锁定
						<?php }?>
						&nbsp;&nbsp;
					</td>
					<td>
					<?php if($value['shopinfo']['shop_commend']==1) {?>
						<img src="<?php echo $this->_webroot('skin/images/yes.gif'); ?>" onclick="toggle_show(this,'no','<?php echo $value['shopinfo']['id'];?>')" style="cursor:pointer;" alt="前台只显示七家店铺"/>
						<?php }else{?>
						<img src="<?php echo $this->_webroot('skin/images/no.gif'); ?>" onclick="toggle_show(this,'yes','<?php echo $value['shopinfo']['id'];?>')" style="cursor:pointer;" alt="前台只显示七家店铺"/>
						<?php }?>
						&nbsp;&nbsp;
					
					</td>
					<td><?php if($value['user']['rank_id']==1) {echo "<span>未通过</span>";} else {echo $userrank[$value['user']['rank_id']]['rank_name'];} ?></td>
					<td><?php echo substr($value['shopinfo']['created'],0,10);?></td>
					<td>
						<a onclick="return confirm('确定要下架名表行下的所有商品吗?');" href="<?php echo $this->_url('admin/shop/goodsdownsale/?id='.$value['shopinfo']['id']);?>">下架商品</a>
						<br />
						<a href="<?php echo $this->_url('admin/user/edit/'.$value['shopinfo']['user_id']);?>">修改级别</a><br />
						<?php if($value['shopinfo']['lock_flg']==0){?>
						<a onclick="return confirm('您确定要锁定名表行商铺，该商铺下的商品同时下架！')" href="<?php echo $this->_url('admin/shop/lockshop/?id='.$value['shopinfo']['id']);?>&v=1">锁定商铺</a><br />
						<?php }else{?>
						<a href="<?php echo $this->_url('admin/shop/lockshop/?id='.$value['shopinfo']['id']);?>&v=0" >解除锁定</a><br />
						<?php }?>
						<a href="<?php echo $this->_url('admin/shop/shopedit/?id='.$value['shopinfo']['id']);?>" >修改商铺</a>
					</td>
				</tr>
				<?php }?>
				<tr>
					<td colspan="15">
						<span style="margin:14px 14px 0px 0px; float:left;" >
                            <select name="v">
								<option value="1">锁定商铺</option>
								<option value="0">解除锁定</option>
							</select>
						</span>
						<span class="button-container"><input class="regular-button" type="submit" name=""  onclick="return delcheck();" value="批量操作" /></span>
						<span class="button-container"><input class="regular-button" type='button' onclick='jump_diff("<?php echo $this->_url('admin/shop/goodsdownsale/?');?>");' value='批量下架' /></span>
					</td>
				</tr>
				<?php } else { ?>
				<tr>
					<td colspan="9">暂无信息</td>
				</tr>
				<?php } ?>
				<tr>
					<td colspan="9">
					<a href="<?php echo $result['page']['head'];?>">首页</a> 
                            <a href="<?php echo $result['page']['prevPage'];?>">上一页</a> 
                            <?php foreach($result['page']['plist'] as $k => $v ) { ?>							
                            <a href="<?php echo $v; ?>"><?php echo $k; ?></a>
							<?php } ?>
                            <a href="<?php echo $result['page']['nextPage'];?>">下一页</a> 
                            <a href="<?php echo $result['page']['foot'];?>">尾页</a> 
                            当前第<?php echo $result['page']['current']['num'];?>页/共<?php echo $result['page']['pageCount'];?>页
					</td>
				</tr>
				</tbody>
				<input type="hidden" name="test" id="test"/>
			</table>
			</form>
	  </div>
	 </div>
	</div>
</div>
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js'); ?>"></script>
<script language="JavaScript">
<!--

function toggle_show(obj,yn,id){
	var re = /yes/i;
	var src = obj.src;
	var s = 1;
	var searchv = src.search(re);
	if(searchv > 0) {
		s = 0;
	}
	ajax("a.php?act=shopcommend","POST","shopid="+id+"&shopcommend="+s,function(data){
		if(data) {
			var arraydata = data.split(".");
			if(arraydata[2]=="1")
			{
				ShowMessageBox("商店尚未通过,不能推荐！",'0');
				return;
			}
			if(arraydata[2]=="2")
			{
				ShowMessageBox("商铺被锁定，不能推荐！",'0');
				return;
			}
			if(arraydata[2]=="3")
			{
				ShowMessageBox("商铺为开放，不能推荐！",'0');
				return;
			}
			if(arraydata[1]>7){
				ShowMessageBox("前台只显示7家店铺,现在已设置了"+arraydata[1]+"家",'0');
				}
			obj.src = '../skin/default/images/'+arraydata[0]+'.gif';
		}
	});
}


var inputs = document.getElementsByTagName("input");

function jump_diff(link_href){
	var checked = false; 
    for (var i = 0; i < inputs.length; i++) 
    {
    	if (inputs[i].checked == true) 
        {
            checked = true;
            if(confirm('确定要执行此操作吗？')){
            	document.getElementById('form1').action=link_href;
            	document.getElementById('form1').submit();
            	break; 
                }else{
                	return false;
                	break; 
                    }
        }
    }
    if (!checked) 
    { 
        ShowMessageBox("请至少选择一个店铺！",'0'); 
        return false; 
    }
    return true;
}
function delcheck(){
	var checked = false; 
    for (var i = 0; i < inputs.length; i++) 
    {
    	if (inputs[i].checked == true) 
        {
            checked = true;
            if(confirm('确定要执行此操作吗？')){
            	break; 
                }else{
                	return false;
                	break; 
                    }
        }
    } 
    if (!checked) 
    { 
        ShowMessageBox("请至少选择一个店铺！",'0'); 
        return false; 
    }
    return true;
}

//-->
</script>
</body>
</html>